﻿<Application x:Class="ConvertSourceToHtml.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cc="clr-namespace:ConvertSourceToHtmlCustomControls;assembly=ConvertSourceToHtmlCustomControls"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <Style x:Key="stylishButtonBorder" TargetType="{x:Type Border}">
            <Setter Property="Background" Value="Maroon" />
            <EventSetter Event="MouseLeftButtonDown" Handler="stylishButton_MouseLeftButtonDown" />
        </Style>

        <Style x:Key="stylishButton" TargetType="{x:Type Border}">
            <Setter Property="Margin" Value="2" />
            <Setter Property="Background">
                <Setter.Value>
                    <SolidColorBrush x:Name="stylishButtonBrush" Color="#7F3E3E" />
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <EventTrigger RoutedEvent="Border.MouseLeftButtonDown">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)" 
                                            To="Maroon" Duration="0" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger RoutedEvent="Border.MouseLeftButtonUp">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)" 
                                            To="#7F3E3E" Duration="0:0:0.2" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger RoutedEvent="Border.MouseLeave">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)" 
                                            To="#7F3E3E" Duration="0:0:0.2" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="stylishButtonText" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Foreground" Value="White" />
        </Style>
        
        <Style x:Key="closeMinimizeButtons" TargetType="{x:Type Path}">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Stroke" Value="Gray" />
            <Setter Property="StrokeThickness" Value="3" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Stroke" Value="#555555" />
                </Trigger>
            </Style.Triggers>
        </Style>
        
        <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ Theme of the NumericUpDownContol ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <SolidColorBrush x:Key="ListBorder" Color="#7F5E43"/>

        <LinearGradientBrush x:Key="TopButtonNormalBrush" StartPoint="0,0" EndPoint="1,2">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="#8C4D4D" Offset=".2"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="TopButtonHoverBrush" StartPoint="0,0" EndPoint="1,2">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="#A85C5C" Offset=".2"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="TopButtonPressedBrush" StartPoint="0,0" EndPoint="1,2">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="#893232" Offset=".2"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="BottomButtonNormalBrush" StartPoint="0,-1" EndPoint="1,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#8C4D4D" Offset=".8"/>
                <GradientStop Color="#893232" Offset="1"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="BottomButtonHoverBrush" StartPoint="0,-1" EndPoint="1,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#A85C5C" Offset=".8"/>
                <GradientStop Color="#AF5050" Offset="1"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="BottomButtonPressedBrush" StartPoint="0,-1" EndPoint="1,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#893232" Offset=".8"/>
                <GradientStop Color="#871B1B" Offset="1"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <Style TargetType="{x:Type RepeatButton}" x:Key="SharedStyle">
            <Setter Property="Height" Value="9"/>
            <Setter Property="Width" Value="17"/>
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Margin" Value="0 .25 0 .25"/>
        </Style>

        <Style TargetType="{x:Type RepeatButton}" x:Key="TopButton" BasedOn="{StaticResource SharedStyle}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Border Name="TopButtonBorder" BorderThickness="0" CornerRadius="2 2 0 0" 
              Margin="1 1 1 .5" Background="{StaticResource TopButtonNormalBrush}">

                            <Polygon Points="3,6 7.5,2 12,6 8.5,6 7.5,5 6.5,6"  StrokeThickness="1" Fill="White"
               StrokeLineJoin="Round" Canvas.Left="1" Canvas.Top="1"/>

                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="TopButtonBorder" Property="Background" 
                  Value="{StaticResource TopButtonHoverBrush}"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="TopButtonBorder" Property="Background" 
                  Value="{StaticResource TopButtonPressedBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type RepeatButton}" x:Key="BottomButton" BasedOn="{StaticResource SharedStyle}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Border Name="BottomButtonBorder" BorderThickness="0" CornerRadius="0 0 2 2" 
              Margin="1 .5 1 1" Background="{StaticResource BottomButtonNormalBrush}">

                            <Polygon Points="3,2 7.5,6 12,2 8.5,2 7.5,3 6.5,2"  StrokeThickness="1" Fill="White"
           StrokeLineJoin="Round" Canvas.Left="1" Canvas.Top="1"/>

                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="BottomButtonBorder" Property="Background" 
                  Value="{StaticResource BottomButtonHoverBrush}"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="BottomButtonBorder" Property="Background" 
                  Value="{StaticResource BottomButtonPressedBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <Style TargetType="{x:Type cc:NumericUpDown}">
            <Setter Property="BorderBrush"
        Value="{StaticResource ListBorder}"/>
            <Setter Property="BorderThickness"
        Value="1"/>
            <Setter Property="Padding"
        Value="0"/>
            <Setter Property="MinWidth"
        Value="47"/>
            <Setter Property="Height"
        Value="21"/>
            <Setter Property="HorizontalAlignment" 
        Value="Center"/>
            <Setter Property="VerticalAlignment" 
        Value="Center"/>
            <Setter Property="FocusVisualStyle">
                <Setter.Value>
                    <Style>
                        <Setter Property="Control.Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Border>
                                        <Rectangle Margin="1"
                         StrokeThickness="1"
                         Stroke="Black"
                         StrokeDashArray="1 2"/>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type cc:NumericUpDown}">
                        <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Padding="{TemplateBinding Padding}">
                            <Grid>

                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>

                                <TextBlock Text="{TemplateBinding ValueString}" 
              TextAlignment="Right" VerticalAlignment="Center" Grid.RowSpan="2" Margin="2 0 5 2"/>

                                <RepeatButton Command="cc:NumericUpDown.IncreaseCommand" 
                        Grid.Column="1" Grid.Row="0"
                        Style="{StaticResource TopButton}"/>
                                <RepeatButton Command="cc:NumericUpDown.DecreaseCommand" 
                        Grid.Column="1" Grid.Row="1"
                        Style="{StaticResource BottomButton}"/>

                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>
